package cn.xuetian.spring.framework.custom;

import cn.xuetian.spring.framework.component.X;
import cn.xuetian.spring.framework.component.Y;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

@Component
public class BeanPostProcessorImpl implements BeanPostProcessor {


    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        if (beanName.equals("y")) {
            Y bean1 = (Y) bean;

            bean1.setY1("sdfsadkfjsakldfjsakdfjskdf~~~~~~~~~~~");

            return bean1;
        }

        return bean;
    }
}
